<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Spinatiev Ivan
 * Date: 10/11/12
 * Time: 10:33 AM
 * To change this template use File | Settings | File Templates.
 */


class Db_Products_Tags extends Common {
	protected static $tableName = TAB_TAGS;
	protected static $dbFields = array(
		'id',
		'tg_name',
		'deleted'
	);

	/**
	 * @var Db_Products_Tags
	 */
	public $objectArray;

	public $id;
	public $tg_name;
	public $deleted;

	function __construct($value=NULL, $fieldName=NULL) {
		parent::__construct($value, $fieldName);
	}

	public static function getAllTags(){
		$sql = 'SELECT  `tg`.*, `prt`.`prt_product_id` as `productId` FROM ?f AS `tg`
                LEFT JOIN ?f AS `prt` ON `prt`.`prt_tag_id` = `tg`.`id`
                WHERE `tg`.`deleted` = 0 GROUP BY `tg`.`tg_name`';
		return self::$DB->select($sql, self::$tableName, TAB_PRODUCT_TAGS);
	}
}